package com.fileshare.web.dto.Bo;

import com.fileshare.web.entity.Article;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ArticleBo {
    private String title;
    private String summary;
    private String content;
    private Boolean hasPayment;
    private Boolean hasResource;
    private Boolean hasLimit;
    private Boolean selfView;
    private Boolean allowLikes;
    private String status;
    private Boolean allowComment;
    private String coverImage;
    private List<String> fileSeqs;
    private String categorySeq;
    private String documentType;
    private List<String> labels;

    public static Article toEntity(ArticleBo articleBo) {
        Article article = new Article();
        BeanUtils.copyProperties(articleBo, article);
        return article;
    }

    public static List<Article> toEntities(List<ArticleBo> articleBos) {
        return articleBos.stream().map(ArticleBo::toEntity).collect(Collectors.toList());
    }
}
